<template>
	<div class="box">
		<down-menu  :menuItem="shopListDropDownMenu" :menuItemClick="shopClickEvent">
		</down-menu>
	</div>
</template>
<script>
	import DropDownMenu from "../../../edit-components/DropdownMenu";
	import axios from "axios";
	import { mapGetters } from "vuex";
	export default {
		data() {
			return {
				shopListDropDownMenu: [],
			}
		},
		computed: {
		},
		methods: {
			typeClickEvent(item) {
				this.$emit("typeChange", item);
			},
			async shopClickEvent(item) {
				this.$emit("shopChangeCopy", item);
				await this.getTemplate(item.storeCode)
				window.api.storeCode = item.storeCode
				window.api.storeId = item.storeId
				// localStorage.setItem("storeCode",item.storeCode)
				// localStorage.setItem("storeId",item.storeId)
				//设置门店id
			},
			getTemplate(storeCode) {
				let url = api.base_host + '/templateConfig/selectTemplateConfigList';
				let config = {
					url: url,
					method: 'GET',
					headers: {
						sessionId: getCookie("sessionId")
					},
					params: {
						storeCode: storeCode
					}
				};
				return axios(config).then((res) => {
					console.log("打印模板信息",res.data.data)
					// this.$store.commit('setConfigParams', Object.assign(
					// 	this.$store.getters.getConfigParams, {
					// 		templateConfigList: res.data.data
					// 	}
					// ));
				});
			},
			//获取门店信息
			getstorecode() {
				// let url = api.base_host + '/baseStore/getStoreInfo';
				// let url = api.base_host + '/baseStore/getRestStore';
				let url = api.base_host + '/baseStore/findAllStore'
				let config = {
					url: url,
					method: 'GET',
					headers: {
						sessionId: getCookie("sessionId")
					},
				};
				axios(config).then((res) => {
					var arrdata = res.data.data
					var arr = []
					for(var i = 0; i < arrdata.length; i++) {
						let obj = {
							name: arrdata[i].storeName,
							storeCode: arrdata[i].storeCode,
							storeId: arrdata[i].storeCode,
							eqIndex:i
						}
						arr.push(obj)
					}
					this.shopListDropDownMenu = arr
				})
			},
		},
		components: {
			"down-menu": DropDownMenu
		},
		mounted() {
			this.getstorecode()
		},
	}
</script>
<style scoped>
	.box {
        float: left;
        border: 1px solid #eee;
        padding: 0 5px;
        width: 305px;
        height: 28px;
        line-height: 28px;
	}
	.box .el-dropdown{
		border:none;
		line-height:24px;
	}
</style>